#include "memfun.h"
int printfMem(void * pdata,int len)
{
	uint8 * pdataa = (uint8 *)pdata;
	char  pstr[300] = {0};
	char  szstr[170] = {0};
	DWORD flOldProtect;
	DWORD flOldProtect2;
	VirtualProtectEx(::GetCurrentProcess(),(LPVOID)pdata,len,PAGE_READWRITE, &flOldProtect);
	for(int i = 0,j = 0;j<len;i+=2,j++)
	{
		if (j%0x10 == 0)
		{
			sprintf(pstr,"%08x",(int)&pdataa[j]);
			strcat(pstr," ");
			i = 9;
		}
		char temp = pdataa[j] / 0x10;
		if(temp >9)
		{
			temp += ('A' - 10);
		}
		else
		{
			temp += '0';
		}
		pstr[i]   = temp;
		temp = pdataa[j] % 0x10;
		if(temp >9)
		{
			temp += ('A'- 10);
		}
		else
		{
			temp += '0';
		}
		pstr[i+1] = temp;
		strcat(pstr," ");
		i+=1;
		if (j%0x10 == 0xf)
		{
			char *pdst = (char *)pdata;
			memcpy(szstr,&pdst[(j/0x10) * 0x10 ],16);
			mylog("%s\r\n",(char *)pstr);
			memset(pstr,0,300);
			//mylog("%s %s\r\n",(char *)pstr,szstr);
			i = 0;
		}
	}
	VirtualProtectEx(::GetCurrentProcess(),(LPVOID)pdata,len,flOldProtect, &flOldProtect2);
	if (len%0x10)
	{
		char *pdst = (char *)pdata;
		memcpy(szstr,&pdst[(len/0x10) * 0x10 ],len%0x10);
		mylog("%s %s\r\n",(char *)pstr,szstr);
	}
	return 0;
}